import request from 'umi-request';

export async function queryRule(params = {}) {
  return request('/hr-ssc/api/api-admin/common/getMailLog', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      name:params.name,
      receive:params.receive,
      sendName:params.sendName
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getEmployeeById(id = {}) {
  return request(`/hr-ssc/api/api-admin/newEmployees/getEmployeeById/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function sendMail(params) {
  return request('/hr-ssc/api/api-admin/common/sendMail', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res.flag;
  });
}

export async function getQRCode(params) {
  return request('/hr-ssc/api/api-admin/common/qrimage', {
    method: 'get',
    params: {
      url: params,
    },
  }).then((res) => {
    return res.data;
  });
}

export async function getEncryptId(id) {
  return request('/hr-ssc/api/api-admin/common/sendAesId', {
    method: 'get',
    params: {id},
  }).then((res) => {
    if (res.flag)
      return res.data;
    return null;
  });
}
